//
//  XMBaseModel.m
//  XMKit
//
//  Created by chenming on 2017/11/1.
//  Copyright © 2017年 ChenXiaoMing. All rights reserved.
//

#import "XMBaseModel.h"

@implementation XMBaseModel

- (instancetype)initWithXMDataModelDict:(NSDictionary *)dict {
    if (!dict || ![dict isKindOfClass:[NSDictionary class]]) {
        return nil;
    }
    if (self = [super init]) {
        //     直接赋值的处理
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}

+ (instancetype)XMDataWithModeldict:(NSDictionary *)dict {
    return [[[self class] alloc] initWithXMDataModelDict:dict];
}

- (void)setValue:(id)value forKey:(NSString *)key {
    
    if ([value isKindOfClass:[NSNull class]]) {
        
        return;
    }
    [super setValue:value forKey:key];
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

- (void)setNilValueForKey:(NSString *)key {
   
}

// 当model中与关键字冲突,使用这个方法替换
/*
 - (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if([key isEqualToString:@"id"]) {
        self.ID = value;
        return;
    }
 }
 */

@end
